package com.xiaoma.provider.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/provider")
public class HellowordController {
    @Autowired
    private RedisTemplate redisTemplate;

    @Autowired
    private MyHealthChecker myHealthChecker;

    @GetMapping("/hi")
    public String sayHi() {
        redisTemplate.opsForValue().set("a","123456");
        return "sayHi";
    }
    @GetMapping("/hi2")
    public String sayHi2() {
        return "sayHi";
    }


    @RequestMapping("/up")
    public String up(@RequestParam("up") Boolean up) {
        myHealthChecker.setUp(up);
        return myHealthChecker.isUp()?"UP":"DOWN";
    }
}
